from classes import album


def get_template(album: album.Album):
    genres = album.getGenre("/")
    subgenres = album.getSubgenre("/")

    albumartists = album.getAlbumArtist()
    artists = [artist for artist in album.getArtist() if not artist in albumartists]

    template = f"{album.tracks[0].albumartist} — {album.getAlbum()}\n"

    template += "Genre: "
    for genre in genres:
        template += f"{genre}, "
    template = template[:-2]

    template += "\nSubgenre: "
    for subgenre in subgenres:
        template += f"{subgenre}, "
    template = template[:-2]

    template += f"\nRelease Date: {album.getReleaseDate().strftime('%d %B %Y')}\n\n"
    template += f"# #Album #EP\n\n"

    for albumartist in albumartists:
        template += f"#{albumartist.replace(' ', '').replace('.', '')} "
    template = template[:-1]

    for artist in artists:
        template += f"#{artist.replace(' ', '').replace('.', '')} "
    template = template[:-1]
    template += "\n\n"

    for genre in genres:
        template += f"#{genre.replace(' ', '').replace('-', '').replace('&', 'and').replace('’', '')} "
    template = template[:-1]
    template += "\n"

    for subgenre in subgenres:
        template += f"#{subgenre.replace(' ', '').replace('-', '').replace('&', 'and').replace('’', '')} "
    template = template[:-1]
    template += "\n\n"

    template += "Tracklist:\n"
    for num, track in enumerate(album.tracks):
        template += f"{num + 1}. {track.artist} — {track.title} ["
        for genre in track.genre.split("/"):
            template += f"{genre} / "
        template = template[:-3]
        template += "]\n"

    return template
